extends layout

block content
    #play
        ul
            each item in list
                if item.is_checked==1
                    li.no_sel(data-bid=item.id)
                else
                    li.sel(data-bid=item.id)
    script.
        $(function(){
            var $playLi = $('#play').find('li.no_sel');
            $('#play').on('touchstart','li.no_sel',function(){
                $(this).addClass('animated bounceIn');
                var bid = $(this).attr("data-bid");
                var This = this;
                setTimeout(function(){
                    $.ajax({
                        type: "POST",
                        url: '/api/winning',
                        data: {bid},
                        dataType: 'json',
                        success:function(data){
                            if(data.code === 0){
                                $(This).attr('class','sel');
                                setTimeout(function(){
                                    alert('恭喜你获得：'+ data.good);
                                },100);
                            }
                            var noSelLen = $('#play').find('li.no_sel').length;
                            if (noSelLen === 0) {
                                setTimeout(function(){
                                    $.ajax({
                                        url: '/api/addBox',
                                        data: {count:$('#play').find('li').length},
                                        dataType: 'json',
                                        success:function(data){
                                            if(data.code === 0){
                                                window.location.reload();
                                            }
                                        }
                                    });
                                },100)
                            }
                        }
                    });
                },1000)
            });
        })